package com.inossem.warehousestorage_inossem.adapter.inventory.chuangyou;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.inossem.warehousestorage_inossem.R;
import com.inossem.warehousestorage_inossem.bean.inventory.chuangyou.InventoryPapersBean;

import java.util.List;

/**
 * TODO
 *
 * @author 詹建宇
 * @time on 2018/3/30 15:01
 * @email jianyu.zhan@inossem.com
 */
public class InventoryPapersAdapter extends BaseAdapter {

    private Context context;
    private List<InventoryPapersBean.PaperBodyBean> list;

    public InventoryPapersAdapter(Context context, List<InventoryPapersBean.PaperBodyBean> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder;
        if (view == null) {
            view = LayoutInflater.from(context).inflate(R.layout.cy_view_inventory_list_item, null);
            holder = new ViewHolder();
            holder.inventoryVoucher = (TextView) view.findViewById(R.id.inventoryVoucher);
            holder.planDate = (TextView) view.findViewById(R.id.planDate);
            holder.inventoryState = (TextView) view.findViewById(R.id.inventoryState);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }

        InventoryPapersBean.PaperBodyBean bean = list.get(i);
        holder.inventoryVoucher.setText(String.valueOf(bean.getStocktake_code()));
        holder.planDate.setText(String.valueOf(bean.getBegin_date() + "到" + bean.getEnd_date()));
        holder.inventoryState.setText(String.valueOf(bean.getStock_status_name()));

        return view;
    }

    private class ViewHolder {
        private TextView inventoryVoucher, planDate, inventoryState;
    }
}
